<html>
<head><meta charset="utf-8"><title>bindgen failure with latest nightly · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html">bindgen failure with latest nightly</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="237725175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725175">(May 06 2021 at 20:43)</a>:</h4>
<p>Hello!<br>
I updated my code to the latest nightly-2021-05-06 and it generate rust bindings for <code>linux/perf_event.h</code> (linux perf event API) and the generated code now fails with the following error:</p>
<div class="codehilite"><pre><span></span><code>error: dereferencing a null pointer
        --&gt; /var/lib/cargo/target/x86_64-unknown-linux-gnu/release/build/project-&lt;hash&gt;/out/perf_event.rs:2762:19
         |
    2762 |         unsafe { &amp;(*(::std::ptr::null::&lt;perf_branch_entry&gt;())).to as *const _ as usize },
         |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
</code></pre></div>



<a name="237725319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725319">(May 06 2021 at 20:44)</a>:</h4>
<p>Does someone know where I can find some information about this change?</p>



<a name="237725605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725605">(May 06 2021 at 20:46)</a>:</h4>
<p>There's a conversation in <a href="#narrow/stream/131828-t-compiler/topic/New.20lint.20for.20deref'ing.20a.20NULL.20pointer/near/233920127">https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/New.20lint.20for.20deref'ing.20a.20NULL.20pointer/near/233920127</a></p>
<p>I think the fix is to update the code generator to use <a href="https://doc.rust-lang.org/std/ptr/macro.addr_of.html">https://doc.rust-lang.org/std/ptr/macro.addr_of.html</a> instead.</p>



<a name="237725620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725620">(May 06 2021 at 20:46)</a>:</h4>
<p>I am trying to understand how to make it compile again. Does it require a fix from bindgen? Or is this a false positive that to be fixed directly in rust?</p>



<a name="237725640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725640">(May 06 2021 at 20:46)</a>:</h4>
<p>oh ok</p>



<a name="237725874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237725874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237725874">(May 06 2021 at 20:48)</a>:</h4>
<p>As it's a lint, I suspect you can <code>allow</code> it temporarily as a workaround, but not that it really does generate a pattern that's UB in LLVM-IR.</p>



<a name="237726025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237726025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237726025">(May 06 2021 at 20:49)</a>:</h4>
<p>Ok thank you very much! I am surprised there is not already an issue on bindgen github^^</p>



<a name="237729081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/bindgen%20failure%20with%20latest%20nightly/near/237729081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/bindgen.20failure.20with.20latest.20nightly.html#237729081">(May 06 2021 at 21:05)</a>:</h4>
<p>Created <a href="https://github.com/rust-lang/rust-bindgen/issues/2049">https://github.com/rust-lang/rust-bindgen/issues/2049</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>